/**
 * ZhiZun.com Inc.
 * Copyright (c) 2004-2010 All Rights Reserved.
 */
package com.zhz.lib.cms.manage;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.actions.DispatchAction;
import org.springframework.transaction.support.TransactionTemplate;

import com.zhz.lib.cms.utils.zhz.ZhzHttpRequestUtil;
import com.zhz.project.common.util.hibernate.BaseDAO;

/**
 *
 * @author liwei2672
 * @version $Id: BaseAction.java, v 0.1 2010-7-17 下午09:59:16 liwei2672 Exp $
 */
public class BaseAction extends DispatchAction {
    protected BaseDAO             baseDao;
    //事务模板
    protected TransactionTemplate transactionTemplate;
    //每页显示的条数
    protected Integer             pageSize = 15;

    /**
     * 翻页
     *
     * @param request
     * @param table
     * @param key
     * @param entryTatal
     * @param whereStatement
     * @param LIST
     */
    @SuppressWarnings("unchecked")
    protected List getListWithFanyeHref(HttpServletRequest request, final String table,
                                        String whereStatement, final String ordey, String LIST,
                                        StringBuffer fanyeHref) {
        return ZhzHttpRequestUtil.getListWithFanyeHref(request, baseDao, table, whereStatement,
            ordey, pageSize, LIST, fanyeHref);
    }

    /**
     *对选择的记录进行删除
     *
     * @param request
     * @param table
     * @param key
     */
    protected void delete(HttpServletRequest request, final String table, final String key) {
        ZhzHttpRequestUtil.delete(request, baseDao, table, key);
    }
    /**
     *对选择的多个记录进行删除
     *
     * @param request
     * @param table
     * @param key
     */
    protected void deleteAll(HttpServletRequest request, final String table, final String key) {
        ZhzHttpRequestUtil.deleteAll(request, baseDao, table, key);
    }

    /**
     * 获取记录
     * @param request 
     *
     * @param mapping
     * @param form
     * @param request
     * @param KEY 
     * @param TABLE 
     * @param response
     * @return
     * @throws Exception
     */
    protected Object getRecord(HttpServletRequest request, String TABLE, String KEY, String name) {
        return ZhzHttpRequestUtil.getRecord(request, baseDao, TABLE, KEY, name);
    }

    public void setBaseDao(BaseDAO baseDao) {
        this.baseDao = baseDao;
    }

    public void setTransactionTemplate(TransactionTemplate transactionTemplate) {
        this.transactionTemplate = transactionTemplate;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

}
